<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>.self修饰符</title>
    <script src="js/vue.js"></script>
    <style>
        .divDefault{
            background-color: red;
            width: 200px;
            height: 100px;
        }

        #div1{
            background-color: blue;
            height: 50px;
        }
    </style>
</head>

<body>
    <!-- 五个事件修饰符 .stop .prevent .capture  .once  .self -->
    <div id="app" class="divDefault">
        <div id="div1" @click.self="divHandlerClick">
            <!-- 将事件流改为捕获模式，父元素上添加.capture -->
            <!-- <div id="div1" @click.capture="divHandlerClick"> -->
            <input type="button" value="单击" @click.once="btnHandlerClick">
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {

            },
            methods: {
                divHandlerClick() {
                    alert("div点击事件")
                },
                btnHandlerClick() {
                    alert("按钮点击事件")
                }
            }
        })
    </script>
</body>

</html>